#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int N, by;
    bool sorted = false;

    printf("Enter how many numbers ?\n");
    scanf("%d", &N);

    int a[N], 
        unsorted_until_index = N - 1;
    printf("Enter %d numbers to be sorted: ", N);
    for (int i = 0; i < N; i++)
        scanf("%d", &a[i]);
    
    while (!sorted)
    {
        sorted = true;
        for (int i = 0; i < unsorted_until_index; i++)
        {
            if (a[i] > a[i + 1])
            {
                by = a[i];
                sorted = false;
                a[i] = a[i + 1];
                a[i + 1] = by;
            }
        }
        unsorted_until_index -= 1;
    }
    
    for (int i = 0; i < N; i++)
        printf("%d ", a[i]);

    return 0;
}